import java.awt.BorderLayout;
import java.awt.Graphics;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;

/**
 * @author Team Name: ByteCode
 * Team members: Kevin Conner, Vinesh Thakur, and James Yu
 *  MancaaBoardPanel class contains all the pits of the mancala
 */
public class MancalaBoardPanel extends JPanel{
   /**
    * MancalaBoardPanel constructor sets up the pit components of the mancala board
    * @param style chooses GUI style for the board
    * @param data MancalaDataModel passes the information from the data model
    */
   public MancalaBoardPanel(int style, MancalaDataModel data){
      JPanel mpp1 = new JPanel();
      MancalaPitComponent mpc1 = new MancalaPitComponent(75,100,16,data);
      MancalaPitComponent mpc2 = new MancalaPitComponent(75,100,26,data);
      MancalaPitComponent mpc15 = new MancalaPitComponent(50,50,15,data);
      MancalaPitComponent mpc14 = new MancalaPitComponent(50,50,14,data);
      MancalaPitComponent mpc13 = new MancalaPitComponent(50,50,13,data);
      MancalaPitComponent mpc12 = new MancalaPitComponent(50,50,12,data);
      MancalaPitComponent mpc11 = new MancalaPitComponent(50,50,11,data);
      MancalaPitComponent mpc10 = new MancalaPitComponent(50,50,10,data);

      MancalaPitComponent mpc20 = new MancalaPitComponent(50,50,20,data);
      MancalaPitComponent mpc21 = new MancalaPitComponent(50,50,21,data);
      MancalaPitComponent mpc22 = new MancalaPitComponent(50,50,22,data);
      MancalaPitComponent mpc23 = new MancalaPitComponent(50,50,23,data);
      MancalaPitComponent mpc24 = new MancalaPitComponent(50,50,24,data);
      MancalaPitComponent mpc25 = new MancalaPitComponent(50,50,25,data);

      if(style == 0)
      {
         mpc1.setStrategy(new MancalaStrategyNormal());
         mpc2.setStrategy(new MancalaStrategyNormal());
         mpc15.setStrategy(new MancalaStrategyNormal());
         mpc14.setStrategy(new MancalaStrategyNormal());
         mpc13.setStrategy(new MancalaStrategyNormal());
         mpc12.setStrategy(new MancalaStrategyNormal());
         mpc11.setStrategy(new MancalaStrategyNormal());
         mpc10.setStrategy(new MancalaStrategyNormal());

         mpc20.setStrategy(new MancalaStrategyNormal());
         mpc21.setStrategy(new MancalaStrategyNormal());
         mpc22.setStrategy(new MancalaStrategyNormal());
         mpc23.setStrategy(new MancalaStrategyNormal());
         mpc24.setStrategy(new MancalaStrategyNormal());
         mpc25.setStrategy(new MancalaStrategyNormal());
      }
      else
      {
         mpc1.setStrategy(new MancalaStrategyAlt());
         mpc2.setStrategy(new MancalaStrategyAlt());
         mpc15.setStrategy(new MancalaStrategyAlt());
         mpc14.setStrategy(new MancalaStrategyAlt());
         mpc13.setStrategy(new MancalaStrategyAlt());
         mpc12.setStrategy(new MancalaStrategyAlt());
         mpc11.setStrategy(new MancalaStrategyAlt());
         mpc10.setStrategy(new MancalaStrategyAlt());

         mpc20.setStrategy(new MancalaStrategyAlt());
         mpc21.setStrategy(new MancalaStrategyAlt());
         mpc22.setStrategy(new MancalaStrategyAlt());
         mpc23.setStrategy(new MancalaStrategyAlt());
         mpc24.setStrategy(new MancalaStrategyAlt());
         mpc25.setStrategy(new MancalaStrategyAlt());
      }
      mpp1.setLayout(new BoxLayout(mpp1,0));
      mpp1.setSize(325, 100);
      mpp1.add(mpc15);
      mpp1.add(mpc14);
      mpp1.add(mpc13);
      mpp1.add(mpc12);
      mpp1.add(mpc11);
      mpp1.add(mpc10);
      JPanel mpp2 = new JPanel();
      mpp2.setLayout(new BoxLayout(mpp2, 0));
      mpp2.setSize(325, 100);
      mpp2.add(mpc20);
      mpp2.add(mpc21);
      mpp2.add(mpc22);
      mpp2.add(mpc23);
      mpp2.add(mpc24);
      mpp2.add(mpc25);
      JPanel jp = new JPanel();
      jp.setLayout(new BorderLayout());
      jp.add(mpp1, BorderLayout.NORTH);
      jp.add(mpp2, BorderLayout.SOUTH);
      MancalaPlayerPanel mup = new MancalaPlayerPanel(data);
      jp.add(mup, BorderLayout.CENTER);


      JPanel west = new JPanel();
      west.setLayout(new BoxLayout(west, BoxLayout.Y_AXIS));
      west.add(Box.createVerticalGlue());
      west.add(mpc1);
      west.add(Box.createVerticalGlue());

      JPanel east = new JPanel();
      east.setLayout(new BoxLayout(east, BoxLayout.Y_AXIS));
      east.add(Box.createVerticalGlue());
      east.add(mpc2);
      east.add(Box.createVerticalGlue());

      this.setLayout(new BorderLayout());
      this.add(jp, BorderLayout.CENTER);
      this.add(west, BorderLayout.WEST);
      this.add(east, BorderLayout.EAST);

      MancalaUndoPanel player1 = new MancalaUndoPanel("Player B",data);
      this.add(player1,  BorderLayout.NORTH);

      MancalaUndoPanel player2 = new MancalaUndoPanel("Player A",data);
      this.add(player2,  BorderLayout.SOUTH);
   }

   /**
    * paintComponent draws panel
    */
   public void paintComponent(Graphics g){
      super.paintComponent(g);

   }
}
